
import React,{Component} from "react";
// import FunRefTest from './funRefTest'
import Reftest from "./refTest";

class App extends Component{

  componentDidMount() {
    console.log(this.input.current)
  }

  getFocus = ()=>{
    // console.log(this)
    this.input.current.focus()
  }
  getFocus2 = ()=>{
    // console.log(this.input2.focus());
  }

  render() {
    return (
        <div>
          <Reftest onRef={ (ref)=> this.input = ref } />
          {/*<FunRefTest onRef2={ (ref)=>this.input2 = ref } ></FunRefTest>*/}
          <button onClick={this.getFocus}>获取焦点</button>
          <button onClick={this.getFocus2}>获取函数式组件焦点</button>
        </div>
    )
  }
}


export default App;
